package jiinn.services;

import jiinn.interfaces.ZipcodeDAO;
import jiinn.interfaces.ZipcodeService;
import jiinn.models.ZipcodeVO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("zipcodeService")
public class ZipcodeServiceImpl implements ZipcodeService {

	@Autowired
	private ZipcodeDAO zipcodeDAO;
	
	@Override
	public String readZipcode(String dong) throws Exception {
		String result = "";
		for (ZipcodeVO z : zipcodeDAO.selectZipcode(dong)){
			if (z.getRi() == null) z.setRi("");				
			if (z.getBunji() == null) z.setBunji("");
				
			result += "<option>" + z.getZipcode()+ " "
					+ z.getSido() + " "	+ z.getGugun() + " "
					+ z.getDong() + " "	+ z.getRi() + " "
					+ z.getBunji() + "</option>";
		}		
		return result;
	}

}
